package com.design.observer;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class SwingObserverExample {
	JFrame frame;
	
	public void go() {
		frame = new JFrame();
		JButton jb = new JButton("choose one");
		jb.addActionListener(new AngelListener());
		jb.addActionListener(new DevilListener());
		
		frame.getContentPane().add(BorderLayout.CENTER, jb);
	}
	
	class AngelListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			System.out.println("angle");
		}
		
	}
	
	class DevilListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			System.out.println("devil");
		}
		
	}
	
	public static void main(String[] args) {
		SwingObserverExample ex = new SwingObserverExample();
		ex.go();
	}
}
